package cn.ekuma.epos.subject.model;

import cn.ekuma.data.ui.swing.AbstractDTOTableModel;

import com.openbravo.bean.Product;
import com.openbravo.bean.erp.subject.SubjectProduct;
import com.openbravo.format.Formats;
import com.openbravo.pos.base.AppLocal;

public class SubjectProductTableModel extends AbstractDTOTableModel<SubjectProduct> {

	@Override
	public String[] getColumnNames() {
		return new String[] { AppLocal.getIntString("label.prodref"),
				AppLocal.getIntString("label.prodbarcode"),
				AppLocal.getIntString("label.prodname"),
				AppLocal.getIntString("label.prodpricebuy"),
				AppLocal.getIntString("label.prodpricesell"),
				AppLocal.getIntString("label.baseCustomerPrice"),
				AppLocal.getIntString("label.prodcut.m_sManufacturer"),
				AppLocal.getIntString("label.product.origin"),
				AppLocal.getIntString("label.product.m_iDurability"),
				AppLocal.getIntString("label.prodaux"),
				AppLocal.getIntString("label.product.quantity") };
	}

	public Object getValueAt(int rowIndex, int columnIndex) {
		SubjectProduct subjectProduct = objs.get(rowIndex);
		Product inculdProduct = subjectProduct.getIncludeProduct();
		switch (columnIndex) {
		case 0:
			return inculdProduct.getReference();
		case 1:
			return inculdProduct.getCode();
		case 2:
			return inculdProduct.getName();
		case 3:
			return Formats.CURRENCY.formatValue(inculdProduct.getPriceBuy());
		case 4:
			return Formats.CURRENCY.formatValue(inculdProduct.getPriceSell());
		case 5:
			return Formats.CURRENCY.formatValue(inculdProduct.getM_dCustomerPrice());
		case 6:
			return inculdProduct.getM_sManufacturer();
		case 7:
			return inculdProduct.getM_origin();
		case 8:
			return inculdProduct.getM_iDurability();
		case 9:
			return inculdProduct.isCom() ? "Y" : " ";
		case 10:
			return inculdProduct.getM_quantity();
		}
		return null;
	}

}
